package org.example.sportdemo.controller;

import org.example.sportdemo.utils.OSSUtils;
import org.example.sportdemo.utils.R;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.HashMap;
import java.util.Map;

@RestController
public class AliyunController {

    //上传图片
    @RequestMapping("/upload")
    public R fileUpload(@RequestBody MultipartFile file){
        String url = OSSUtils.putObject(file);
        Map<String,String> map = new HashMap<>();
        map.put("url",url);
        return R.ok().put("data",map);
    }
}
